import {Describer, MONTH_MAP_ARRAY, NUMBER_MAP_CHINESE} from "./base";

export class DatePartDescriber extends Describer {

  // *
  starSegment(exp: '*') {
    return '每天'
  }

  // */3
  starSlashNumberSegment(exp: string) {
    const interval = exp.replace(`*/`, '')
    return `每${interval}天`
  }

  // 1-9/3
  spanSlashNumberSegment(exp: string) {
    const [_, start, end, interval] = exp.match(/^(\d+)-(\d+)\/(\d+)$/)
    return `${NUMBER_MAP_CHINESE[start]}到${NUMBER_MAP_CHINESE[end]}号中的每${interval}天`
  }

  //1-9
  spanSegment(exp: string) {
    const [_, start, end] = exp.match(/^(\d+)-(\d+)$/)
    return `${NUMBER_MAP_CHINESE[start]}到${NUMBER_MAP_CHINESE[end]}号`
  }


  // 3
  singleNumberSegment(exp: string) {
    return `${NUMBER_MAP_CHINESE[exp]}号`
  }

}
